﻿using System.Collections.Generic;
using EYCmsAdmin.Domain.IDomainServices;
using EYCmsAdmin.Domain.Models;
using EYCmsAdmin.Domain.RepositoryInterfaces;

namespace EYCmsAdmin.Domain.DomainServices
{
    public class BaseDomainService<T> : IBaseDomainService<T> where T : IBaseDomainModel 
    {
        public BaseDomainService(IBaseRepository<T> repository)
        {
            Repository = repository;
        }

        public IBaseRepository<T> Repository { get; set; }

        public T Add(T model)
        {
            return Repository.Add(model);
        }

        public T Edit(T model)
        {
            return Repository.Edit(model);
        }

        public void Delete(T model)
        {
            Repository.Delete(model);
        }

        public void Delete(int id)
        {
            Repository.Delete(id);
        }

        public IList<T> GetAll()
        {
            return Repository.GetAll();
        }

        public T Get(int id)
        {
            return Repository.Get(id);
        }
    }
}